/*
 * Created by SharpDevelop.
 * User: David
 * Date: 2006-12-19
 * Time: 23:04
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;

using patterns;

using Labb4.Pooman.Cards;
using Labb4.Pooman.Game;

namespace Labb4.Pooman.Players
{
	/// <summary>
	/// Description of AiControl.
	/// </summary>
	public class PoomanAiControl : PoomanControl
	{
		#region members
		
		/// <summary>
		/// Reference to this control's strategy
		/// </summary>
		private AiStrategy		m_Strategy;
		
		#endregion
		
		#region constructors
		
		/// <summary>
		/// Constructor, initializes members
		/// </summary>
		/// <param name="strategy">Reference to the strategy of this control</param>
		public PoomanAiControl(AiStrategy strategy) :
			base()
		{
			m_Strategy = strategy;
		}
		
		#endregion
		
		#region overrides
		
		/// <summary>
		/// Lets this ai select cards
		/// </summary>
		public override void SelectCards()
		{
			base.SelectCards();
			
			if(m_CurrentPhaseIsOver)
			{
				m_PressedPlay = false;
			}
			else
			{
				m_Strategy.PerformSelectCards(m_Player);
			}
		}
		
		/// <summary>
		/// Lets this ai evaluate some cards. See <see cref="PoomanControl.EvaluateWonCards">abstract base method</see> in PoomanControl
		/// </summary>
		/// <param name="cards">The cards to evaluate</param>
		/// <returns>The result of the evaluation as an enum defined in Player</returns>
		public override Player.Evaluation EvaluateWonCards(CardPile cards)
		{
			return m_Strategy.PerformEvaluateWonCards(m_Player, cards);
		}
		
		/// <summary>
		/// Gets the display type of this players cards as a string
		/// </summary>
		/// <returns></returns>
		public override string DisplayType()
		{
			string displayType = "hidden";
			
			if(Properties.Instance.OpenCards)
			{
				displayType = "normal";
			}
			
			return displayType;
		}
		
		#endregion
	}
}
